<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Manager Tournaments</title>
    </h:head>
    <h:body>
        <h:panelGrid columns="2" border="0">
            <f:view>
                <h:form>
                    <h:dataTable value="#{managerManagedBean.tournaments}" var="item" border="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row">
                        <f:facet name="header">
                            <h:outputText value="The tournaments you are responsible"/>
                        </f:facet>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Name"/>
                            </f:facet>
                            <h:outputText value="#{item.name}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Type"/>
                            </f:facet>
                            <h:outputText value="#{item.type}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Start Date"/>
                            </f:facet>
                            <h:outputText value="#{item.startDate}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="End Date"/>
                            </f:facet>
                            <h:outputText value="#{item.endDate}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Prize"/>
                            </f:facet>
                            <h:outputText value="#{item.prize}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Report"/>
                            </f:facet>
                            <h:outputText value="#{item.report}"/>
                        </h:column>
                        <h:column>
                            <h:commandButton value="Edit" actionListener="#{tournamentManagedBean.linkTournament(item)}" action="manager:editTournament"/>
                            &nbsp;
                            <h:commandButton value="Delete" action="#{managerManagedBean.removeTournament(item)}"/>
                        </h:column>
                    </h:dataTable>
                    <p>
                        <h:commandButton value="Create Tournament" action="createTournament"/>
                    </p>
                </h:form>
            </f:view>
            <f:view>
                <h:panelGrid>
                <h:form>
                    <h:dataTable value="#{managerManagedBean.courts}" var="item" rowClasses="jsfcrud_odd_row,jsfcrud_even_row">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Court Name"/>
                            </f:facet>
                            <h:outputText value="#{item.name}"/>
                        </h:column>
                        <h:column>
                            <h:commandLink value="Remove" action="#{managerManagedBean.removeCourt(item)}"/>
                        </h:column>
                    </h:dataTable>
                </h:form>
                <h:form>
                    <h:panelGrid columns="4">
                        <h:outputText value="Court name:"/>
                        <h:inputText id="courtName" value="#{managerManagedBean.courtName}" required="true" requiredMessage="*"/>
                        <h:message for="courtName" style="color: red"/>
                        <h:commandButton value="Create" action="#{managerManagedBean.addCourt}"/>
                    </h:panelGrid>
                </h:form>
                </h:panelGrid>
            </f:view>

        </h:panelGrid>
    </h:body>
</html>

